import request from "@/utils/request";
import { AxiosPromise } from "axios";

interface menuParams {
  parentId: number;
  name: string;
  href: string;
  icon: string;
  orderName: number;
  description: string;
  show: boolean;
}

export interface menuItem {
  createdBy: string;
  updatedBy: string;
  createdTime: string;
  updatedTime: string;
  parentId: number;
  description: string;
  href: string;
  icon: string;
  id: number;
  level: number;
  name: string;
  orderNum: number;
  shown: boolean;
  selected: boolean;
  subMenuList: null;
}

export const createMenu = (data: menuParams): AxiosPromise => {
  return request({
    method: "POST",
    url: "/boss/menu/saveOrUpdate",
    data,
  });
};

export const getEditMenuInfo = (id: string | number = -1): AxiosPromise => {
  return request({
    method: "GET",
    url: "/boss/menu/getEditMenuInfo",
  });
};

export const getAllMenus = (): AxiosPromise => {
  return request({
    method: "GET",
    url: "/boss/menu/getAll",
  });
};

export const deleteMenu = () => {
  return request({
    method: "DELETE",
    url: "/boss/menu",
  });
};
